package modules
{
	import mx.containers.VBox;
	
	import mx.controls.DataGrid;
	
	import mx.controls.Label;
	
	import mx.controls.dataGridClasses.DataGridColumn;
	
	import mx.controls.dataGridClasses.DataGridListData;
	
	import mx.controls.listClasses.BaseListData;
	
	import mx.controls.listClasses.IDropInListItemRenderer;
	
	
	public class MiddleTextRenderer extends VBox implements IDropInListItemRenderer
		
	{
		
		
		private var displayText:Label = new Label();
		
		private var _listData:DataGridListData;
		
		
		public function MiddleTextRenderer()
			
		{
			
			super();
			
			
			this.percentWidth = 100;
			
			this.percentHeight = 100;
			
			this.setStyle("verticalAlign", "middle");
			
			displayText.percentWidth = 100;
			
			// 希望垂直居中,则去掉下面一行代码的注释
			
			//displayText.setStyle("textAlign", "center");
			
			this.addChild(displayText);
			
		}
		
		
		public function get listData():BaseListData
			
		{
			
			return _listData;
			
		}
		
		
		public function set listData(value:BaseListData):void
			
		{
			
			_listData = DataGridListData(value);
			
		}
		
		
		override public function validateProperties():void
			
		{
			
			if (_listData)
				
			{
				
				var dg:DataGrid = DataGrid(_listData.owner);
				
				
				var column:DataGridColumn =
					
					dg.columns[_listData.columnIndex];
				
				
				displayText.text = _listData.label;
				
			}
				
			else
				
			{
				
				displayText.text = " ";
				
			}
			
			
			super.validateProperties();
			
		}
		
		
	}
	

}